// src/api/mockData/blacklist.ts
import Mock from 'mockjs'
import type { BlacklistUser } from '../../stores/blacklist'

function pad(n: number) { return n.toString().padStart(2, '0') }
function randomDate2025() {
    const m = Mock.Random.integer(1, 12)
    const d = Mock.Random.integer(1, [31,28,31,30,31,30,31,31,30,31,30,31][m-1])
    return `2025-${pad(m)}-${pad(d)}`
}

const generate = (): BlacklistUser[] => {
    return Array.from({ length: 30 }).map((_, i) => ({
        id: i + 1,
        userName: Mock.Random.cname(),      // 随机中文姓名
        userId: `2025${pad(100 + i)}`,
        reason: i % 2 === 0 ? '多次未签到' : '恶意占用',
        triggerType: i % 2 === 0 ? 'NO_SHOW' : 'MALICIOUS',
        startDate: randomDate2025(),
        endDate:   randomDate2025(),
        active: i % 3 !== 0
    }))
}

export default {
    getList: () => ({ code: 0, data: generate() }),
    unban:   () => ({ code: 0, message: '解封成功' }),
    extend:  () => ({ code: 0, message: '延长成功' }),
    appealBlacklist: () => Mock.mock({
        status: true,
        code: 0,
        message: '申诉提交成功，请等待处理',
        data: null
    })
}
